package com.hliushi.learn.repository;

import com.hliushi.learn.entity.TFile;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * TFile Repository层
 *
 * @author auto generated
 * @date 2021-08-17 11:02:03
 */
public interface TFileRepository extends JpaRepository<TFile, String> {


    List<TFile> findByTypeEqualsOrderByIdAsc(String type);


    @Modifying
    @Query(value = "update t_file  set backed_up = 1 where id = ?1", nativeQuery = true)
    void updateBackup(String id);

    @Query(value = "select * from t_file where type = ?1  and backed_up = 0 order by id asc limit 0, ?2",
            nativeQuery = true)
    List<TFile> findByTypeNative(String type, Integer count);
}
